package com.xbb.entity;

import java.util.Date;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.xbb.entity.ServicesType;
import com.xbb.entity.User;

public class Services{

    private static final long serialVersionUID = 1L;

    //  服务ID
    private Integer id;

    //  类型ID
    private Integer servicesTypeId;

    //  名称
    private String name;

    //  展示图
    private String img;

    //  描述
    private String describes;

    //  内容
    private String content;

    //  创建时间
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private Date creatTime;

    //  用户ID
    private Integer userId;

    //  价格
    private Double price;

    //  积分
    private Integer integral;

    //  服务时长
    private String duration;

    //  状态
    private Boolean status;

    private ServicesType servicesType;

    private User user;

    public void setId(Integer id){
        this.id = id;
    }

    public Integer getId(){
        return id;
    }

    public void setServicesTypeId(Integer servicesTypeId){
        this.servicesTypeId = servicesTypeId;
    }

    public Integer getServicesTypeId(){
        return servicesTypeId;
    }

    public void setName(String name){
        this.name = name;
    }

    public String getName(){
        return name;
    }

    public void setImg(String img){
        this.img = img;
    }

    public String getImg(){
        return img;
    }

    public void setDescribes(String describes){
        this.describes = describes;
    }

    public String getDescribes(){
        return describes;
    }

    public void setContent(String content){
        this.content = content;
    }

    public String getContent(){
        return content;
    }

    public void setCreatTime(Date creatTime){
        this.creatTime = creatTime;
    }

    public Date getCreatTime(){
        return creatTime;
    }

    public void setUserId(Integer userId){
        this.userId = userId;
    }

    public Integer getUserId(){
        return userId;
    }

    public void setPrice(Double price){
        this.price = price;
    }

    public Double getPrice(){
        return price;
    }

    public void setIntegral(Integer integral){
        this.integral = integral;
    }

    public Integer getIntegral(){
        return integral;
    }

    public void setDuration(String duration){
        this.duration = duration;
    }

    public String getDuration(){
        return duration;
    }

    public void setStatus(Boolean status){
        this.status = status;
    }

    public Boolean getStatus(){
        return status;
    }

    public ServicesType getServicesType(){
        return servicesType;
    }

    public void setServicesType(ServicesType servicesType){
        this.servicesType = servicesType;
    }

    public User getUser(){
        return user;
    }

    public void setUser(User user){
        this.user = user;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("id", getId())
            .append("servicesTypeId", getServicesTypeId())
            .append("name", getName())
            .append("img", getImg())
            .append("describes", getDescribes())
            .append("content", getContent())
            .append("creatTime", getCreatTime())
            .append("userId", getUserId())
            .append("price", getPrice())
            .append("integral", getIntegral())
            .append("duration", getDuration())
            .append("status", getStatus())
            .toString();
    }

    @Override
    public boolean equals(Object obj) {
        if(this == obj){
            return true;//地址相等
        }
        if(obj == null){
            return false;//非空性：对于任意非空引用x，x.equals(null)应该返回false。
        }
        if(obj instanceof Services){
            Services other = (Services) obj;
            //需要比较的字段相等，则这两个对象相等
            if(equalsStr(this.name, other.getName()) && this.id == other.getId()){
                return true;
            }
        }
        return false;
    }

    private boolean equalsStr(String str1, String str2){
        if(str1.equals(str2)){
            return true;
        }
        return false;
    }

    @Override
    public int hashCode() {
        int result = 17;
        result = 31 * result + (this.name == null ? 0 : this.name.hashCode());
        result = 31 * result + (this.id == null ? 0 : this.id.hashCode());
        return result;
    }

}
